//


import Foundation
import UIKit


//屏幕宽度
let kScreenWidth:CGFloat                  = UIScreen.main.bounds.width
//屏幕高度
let kScreenHeight:CGFloat                 = UIScreen.main.bounds.height
//不同屏幕尺寸字体适配（375，667是因为目前苹果开发一般用IPHONE6做中间层 如果不是则根据实际情况修改）
//相对于iPhone6的宽度比例
func kRatioWidth(_ size:CGFloat) ->CGFloat {
    return size * (kScreenWidth/375)
}
func kRatioHeight(_ size:CGFloat) ->CGFloat {
    return size * (kScreenWidth/375)
}
//
func iPhoneX() -> Bool {
    return UIApplication.shared.statusBarFrame.size.height != 20
}
//状态栏默认高度
let kStatusBarHeight:CGFloat = (iPhoneX() ? 44.0 : 20.0)
//Tabbar默认高度
let kTabBarHeight:CGFloat = (iPhoneX() ? 83.0 : 49.0)
//导航栏默认高度
let kNavBarHeight:CGFloat = 44.0 + kStatusBarHeight
//home indicator
let kHOME_INDICATOR_HEIGHT:CGFloat = (iPhoneX() ? 30.0 : 0)


/// 方正黑体简体字体定义
///
/// - Parameter size: 字体大小
/// - Returns: UIFont
func FontPFThin(_ size:CGFloat) ->UIFont {
    return UIFont.init(name: "PingFangSC-Thin", size:kRatioWidth(size))!
}
func FontPFLight(_ size:CGFloat) ->UIFont {
    return UIFont.init(name: "PingFangSC-Light", size:kRatioWidth(size))!
}
func FontPFMedium(_ size:CGFloat) ->UIFont {
    return UIFont.init(name: "PingFangSC-Medium", size:kRatioWidth(size))!
}
func FontPFRegular(_ size:CGFloat) ->UIFont {
    return UIFont.init(name: "PingFangSC-Regular", size:kRatioWidth(size))!
}
func FontPFBold(_ size:CGFloat) ->UIFont {
    return UIFont.init(name: "PingFangSC-Semibold", size:kRatioWidth(size))!
}

//swift中的写法
func rgb(_ r:CGFloat,_ g:CGFloat,_ b:CGFloat) -> UIColor
{
    return UIColor(red: (r)/255.0, green: (g)/255.0, blue: (b)/255.0, alpha: 1.0)
}
func rgba(_ r:CGFloat,_ g:CGFloat,_ b:CGFloat,_ a:CGFloat) -> UIColor
{
    return UIColor(red: (r)/255.0, green: (g)/255.0, blue: (b)/255.0, alpha: a)
}

let COLORS = rgb(233,222,222)

//// 十六进制值取色(HEX)
func UIColorFromHexA(_ rgbValue:Int ,a:CGFloat) -> UIColor
{
    return UIColor(red: ((CGFloat)((rgbValue & 0xFF0000) >> 16))/255.0, green: ((CGFloat)((rgbValue & 0xFF00) >> 8))/255.0, blue: ((CGFloat)((rgbValue & 0xFF)))/255.0, alpha: a)
}
// 十六进制值取色(HEX)
func UIColorFromHex(_ rgbValue:Int ) -> UIColor
{
    return UIColorFromHexA(rgbValue, a: 1.0)
}

//toast
func showMessage(_ text:String,_ vc:UIView) {
    let mbp = MBProgressHUD.showAdded(to: vc, animated: true)
    mbp.mode = .text
    mbp.label.text = text
    mbp.hide(animated: true, afterDelay: 2)
    
}
